---@class BuffEffect16 : BaseBuffEffect
BuffEffect16 = ClientFight.CreateClass("BuffEffect16", ClientFight.BaseBuffEffect)
local t = BuffEffect16

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local source = buff.source
    local target = buff.target
    local type = 0;
    local value = 0;
    local attrType = 0;
    local attrLimitValue = 0;
    if (buff.buffBean.f_BuffEffectValue ~= nil) then
        type = buff.buffBean.f_BuffEffectValue[1];
        value = buff.buffBean.f_BuffEffectValue[2];
        if (#buff.buffBean.f_BuffEffectValue > 3) then
            attrType = buff.buffBean.f_BuffEffectValue[3];
            attrLimitValue = buff.buffBean.f_BuffEffectValue[4];
        end
    else
        type = buff.addParameters[1];
        value = buff.addParameters[2];
    end
    local subHp = 0;
    if type == 1 then
        subHp = value;
    elseif type == 2 then
        subHp = math.floor(target.hp * Utils.toRatio(value));
    elseif type == 3 then
        local maxHp = FighterAttributeManager.getFightAttr(target, FighterAttributeEnum.HP);
        subHp = math.floor(maxHp * Utils.toRatio(value))
    elseif type == 4 then
        local maxHp = FighterAttributeManager.getFightAttr(target, FighterAttributeEnum.HP);
        local currHp = target.hp
        subHp = math.floor((maxHp - currHp) * Utils.toRatio(value));
    end
    if (attrType > 0) then
        local fightAttr = FighterAttributeManager.getFightAttr(source, attrType);
        local limitValue = math.floor(fightAttr * Utils.toRatio(attrLimitValue));
        if (subHp > limitValue) then
            subHp = limitValue;
        end
    end
    --local logSubHp = subHp;
    SkillRoleMgr.savePathFile( string.format(
    "[%s][EFFECT]Fighter %s Buff%s 触发生命移除,移除%s血量", fight.frame, buff.target.fighterId, buff.modelId, logSubHp
    ));
    local realDamage = DamageManager.setFighterHp(fight, target, source, nil, DamageResultTypeEnum.NORMAL,
            -subHp, target.hp - subHp, true, true, true);--//统计伤害
        return ClientFight.BaseBuffEffect.action(self,fight, buff, ...);
end

t.New()